package boot.spring.controller;

import boot.spring.entity.Tracking;
import boot.spring.service.MystudentsService;
import boot.spring.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/*咨询师角色

我的学生页面的控制层*/
@RequestMapping("/MystudentsController")
@RestController
public class MystudentsController {
    /*注入业务层*/
    @Autowired
    private MystudentsService mystudentsService;

    /*分页多条件查询当前咨询师的学生*/
    @RequestMapping("/ListConUidStuAll")
    public Result ListConUidStuAll(Integer page,Integer limit,Integer uid,String stuname,String ifPay,String qq,String sex){
        return mystudentsService.ListSerUidStuAll( page, limit,uid, stuname, ifPay, qq, sex);
    }

    /*新增一条跟踪日志*/
    @PostMapping("/GetConTraStuAdd")
    public Result GetConTraStuAdd(Tracking add){
        return mystudentsService.GetSerTraStuAdd(add);
    }



    //查看
    @RequestMapping("/Looks")
    public Object Looks(@RequestParam Map<String,Object> map,
                        @RequestParam("page") int page,@RequestParam("limit") int limit,@RequestParam("stuid") String stuid) {
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        map.put("stuid",stuid);
        System.out.println(map);
        return new Result(0,"true",mystudentsService.getCount(map),mystudentsService.Looks(map));
    }

    //网络咨询师添加
    @RequestMapping("/Addstu")
    public Object Addstu(@RequestParam Map<String,Object> map) {
        int list=mystudentsService.Addstu(map);
        Result res=new Result(1,"true",10,list);
        return res;

    }

/*网络咨询师的学生*/
    @RequestMapping("/getAll")
    public Object getAll(@RequestParam Map<String,Object> map,
                         @RequestParam("page") int page,@RequestParam("limit") int limit,@RequestParam("uid") String uid ) {
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        map.put("uid",uid);
        System.out.println(map);
        return new Result(0, "true", mystudentsService.getwangluoCount(map), mystudentsService.getAll(map));
    }
}
